package cn.com.flower.admin.account.service.impl;

import cn.com.flower.admin.account.dao.persist.repository.IUserRepository;
import cn.com.flower.admin.account.pojo.vo.UserStandardVO;
import cn.com.flower.admin.account.service.IUserService;
import cn.com.flower.common.enumerator.ServiceCode;
import cn.com.flower.common.ex.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserRepository userRepository;

    @Override
    public UserStandardVO getStandardById(Long userId) {
        log.debug("开始处理【根据ID查询用户】业务，参数：{}", userId);
        UserStandardVO currentUser = userRepository.getStandardById(userId);
        if (currentUser == null) {
            String message = "获取用户详情失败，尝试访问的用户数据不存在！";
            log.warn(message);
            throw new ServiceException(ServiceCode.ERROR_NOT_FOUND, message);
        }
        return currentUser;
    }
}